// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using System;
using System.Linq;
using Elastic.Clients.Elasticsearch.Serialization;

namespace Elastic.Clients.Elasticsearch;

[System.Text.Json.Serialization.JsonConverter(typeof(Elastic.Clients.Elasticsearch.Json.NestedSortValueConverter))]
public sealed partial class NestedSortValue
{
	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public NestedSortValue(Elastic.Clients.Elasticsearch.Field path)
	{
		Path = path;
	}
#if NET7_0_OR_GREATER
	public NestedSortValue()
	{
	}
#endif
#if !NET7_0_OR_GREATER
	[System.Obsolete("The type contains required properties that must be initialized. Please use an alternative constructor to ensure all required values are properly set.")]
	public NestedSortValue()
	{
	}
#endif
	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	internal NestedSortValue(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel sentinel)
	{
		_ = sentinel;
	}

	public Elastic.Clients.Elasticsearch.QueryDsl.Query? Filter { get; set; }
	public int? MaxChildren { get; set; }
	public Elastic.Clients.Elasticsearch.NestedSortValue? Nested { get; set; }
	public
#if NET7_0_OR_GREATER
	required
#endif
	Elastic.Clients.Elasticsearch.Field Path { get; set; }
}

public readonly partial struct NestedSortValueDescriptor<TDocument>
{
	internal Elastic.Clients.Elasticsearch.NestedSortValue Instance { get; init; }

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public NestedSortValueDescriptor(Elastic.Clients.Elasticsearch.NestedSortValue instance)
	{
		Instance = instance;
	}

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public NestedSortValueDescriptor()
	{
		Instance = new Elastic.Clients.Elasticsearch.NestedSortValue(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
	}

	public static explicit operator Elastic.Clients.Elasticsearch.NestedSortValueDescriptor<TDocument>(Elastic.Clients.Elasticsearch.NestedSortValue instance) => new Elastic.Clients.Elasticsearch.NestedSortValueDescriptor<TDocument>(instance);
	public static implicit operator Elastic.Clients.Elasticsearch.NestedSortValue(Elastic.Clients.Elasticsearch.NestedSortValueDescriptor<TDocument> descriptor) => descriptor.Instance;

	public Elastic.Clients.Elasticsearch.NestedSortValueDescriptor<TDocument> Filter(Elastic.Clients.Elasticsearch.QueryDsl.Query? value)
	{
		Instance.Filter = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.NestedSortValueDescriptor<TDocument> Filter(System.Action<Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor<TDocument>> action)
	{
		Instance.Filter = Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor<TDocument>.Build(action);
		return this;
	}

	public Elastic.Clients.Elasticsearch.NestedSortValueDescriptor<TDocument> MaxChildren(int? value)
	{
		Instance.MaxChildren = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.NestedSortValueDescriptor<TDocument> Nested(Elastic.Clients.Elasticsearch.NestedSortValue? value)
	{
		Instance.Nested = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.NestedSortValueDescriptor<TDocument> Nested(System.Action<Elastic.Clients.Elasticsearch.NestedSortValueDescriptor<TDocument>> action)
	{
		Instance.Nested = Elastic.Clients.Elasticsearch.NestedSortValueDescriptor<TDocument>.Build(action);
		return this;
	}

	public Elastic.Clients.Elasticsearch.NestedSortValueDescriptor<TDocument> Path(Elastic.Clients.Elasticsearch.Field value)
	{
		Instance.Path = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.NestedSortValueDescriptor<TDocument> Path(System.Linq.Expressions.Expression<System.Func<TDocument, object?>> value)
	{
		Instance.Path = value;
		return this;
	}

	[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
	internal static Elastic.Clients.Elasticsearch.NestedSortValue Build(System.Action<Elastic.Clients.Elasticsearch.NestedSortValueDescriptor<TDocument>> action)
	{
		var builder = new Elastic.Clients.Elasticsearch.NestedSortValueDescriptor<TDocument>(new Elastic.Clients.Elasticsearch.NestedSortValue(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance));
		action.Invoke(builder);
		return builder.Instance;
	}
}

public readonly partial struct NestedSortValueDescriptor
{
	internal Elastic.Clients.Elasticsearch.NestedSortValue Instance { get; init; }

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public NestedSortValueDescriptor(Elastic.Clients.Elasticsearch.NestedSortValue instance)
	{
		Instance = instance;
	}

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public NestedSortValueDescriptor()
	{
		Instance = new Elastic.Clients.Elasticsearch.NestedSortValue(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
	}

	public static explicit operator Elastic.Clients.Elasticsearch.NestedSortValueDescriptor(Elastic.Clients.Elasticsearch.NestedSortValue instance) => new Elastic.Clients.Elasticsearch.NestedSortValueDescriptor(instance);
	public static implicit operator Elastic.Clients.Elasticsearch.NestedSortValue(Elastic.Clients.Elasticsearch.NestedSortValueDescriptor descriptor) => descriptor.Instance;

	public Elastic.Clients.Elasticsearch.NestedSortValueDescriptor Filter(Elastic.Clients.Elasticsearch.QueryDsl.Query? value)
	{
		Instance.Filter = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.NestedSortValueDescriptor Filter(System.Action<Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor> action)
	{
		Instance.Filter = Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor.Build(action);
		return this;
	}

	public Elastic.Clients.Elasticsearch.NestedSortValueDescriptor Filter<T>(System.Action<Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor<T>> action)
	{
		Instance.Filter = Elastic.Clients.Elasticsearch.QueryDsl.QueryDescriptor<T>.Build(action);
		return this;
	}

	public Elastic.Clients.Elasticsearch.NestedSortValueDescriptor MaxChildren(int? value)
	{
		Instance.MaxChildren = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.NestedSortValueDescriptor Nested(Elastic.Clients.Elasticsearch.NestedSortValue? value)
	{
		Instance.Nested = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.NestedSortValueDescriptor Nested(System.Action<Elastic.Clients.Elasticsearch.NestedSortValueDescriptor> action)
	{
		Instance.Nested = Elastic.Clients.Elasticsearch.NestedSortValueDescriptor.Build(action);
		return this;
	}

	public Elastic.Clients.Elasticsearch.NestedSortValueDescriptor Nested<T>(System.Action<Elastic.Clients.Elasticsearch.NestedSortValueDescriptor<T>> action)
	{
		Instance.Nested = Elastic.Clients.Elasticsearch.NestedSortValueDescriptor<T>.Build(action);
		return this;
	}

	public Elastic.Clients.Elasticsearch.NestedSortValueDescriptor Path(Elastic.Clients.Elasticsearch.Field value)
	{
		Instance.Path = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.NestedSortValueDescriptor Path<T>(System.Linq.Expressions.Expression<System.Func<T, object?>> value)
	{
		Instance.Path = value;
		return this;
	}

	[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
	internal static Elastic.Clients.Elasticsearch.NestedSortValue Build(System.Action<Elastic.Clients.Elasticsearch.NestedSortValueDescriptor> action)
	{
		var builder = new Elastic.Clients.Elasticsearch.NestedSortValueDescriptor(new Elastic.Clients.Elasticsearch.NestedSortValue(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance));
		action.Invoke(builder);
		return builder.Instance;
	}
}